from django.utils.translation    import ugettext_lazy as _
from sitepal.sitemenu.models     import MenuView
from sitepal.sitetheme.renderers import BlockRenderer

class NavigationBlockRenderer(BlockRenderer):
    def render(self,request):
        def map_link(link):
            return {'url':link.path,'content':link.title,'resolve':'menu'}
        
        path  = request.menu_path if hasattr(request,'menu_path') else ''
        links = MenuView.objects.get_links_for_path(path,request.user,'navigation')
        return self.render_navigation(map(map_link,links),self.attributes)

